package org.jtb.flickrportlet;

public class PageHandler {
    private static final String myPage = "/WEB-INF/jsp/my.jsp";
    private static final String contactsPage = "/WEB-INF/jsp/contacts.jsp";
    private static final String searchPage = "/WEB-INF/jsp/search.jsp";    
    private static final String setUserNamePage = "/WEB-INF/jsp/setUserName.jsp";
    private static final String morePage = "/WEB-INF/jsp/more.jsp";
    private static final String addPage = "/WEB-INF/jsp/add.jsp";
    
    private String page = myPage;
    private String tab = "my";
    
    public String getPage() {
        return page;
    }

    public boolean isMyPage() {
        return getPage().equals(myPage);
    }

    public boolean isContactsPage() {
        return getPage().equals(contactsPage);
    }

    public boolean isSearchPage() {
        return getPage().equals(searchPage);
    }

    public boolean isSetUserNamePage() {
        return getPage().equals(setUserNamePage);
    }
    
    private void setPage(String page) {
        this.page = page;
    }

    public void setTabPage() {
        if (tab.equals("my")) {
            setMyPage();
        } else if (tab.equals("contacts")) {
            setContactsPage();
        } else if (tab.equals("search")) {
            setSearchPage();
        } else {
            throw new IllegalStateException("undefined tab: " + tab);
        }
        
    }

    public void setMyPage() {
        setMyTab();
        page = myPage;
    }

    public void setContactsPage() {
        setContactsTab();
        page = contactsPage;
    }
    
    public void setSearchPage() {
        setSearchTab();
        page = searchPage;
    }

    public void setSetUserNamePage() {
        page = setUserNamePage;
    }

    public void setAddPage() {
        page = addPage;
    }

    public void setMorePage() {
        page = morePage;
    }
    
     public String getTab() {
        return tab;
    }
    
    private void setMyTab() {
        tab = "my";
    }
    
    private void setContactsTab() {
        tab = "contacts";
    }
    
    private void setSearchTab() {
        tab = "search";
    }
   
}
